﻿/*	
	stencil - action script 3 isometric game engine.

	http://code.google.com/p/stencilas3/
	
	Copyright (c) 2010 Max Zhuravkov, All Rights Reserved.

	Permission is hereby granted, free of charge, to any person obtaining a copy of
	this software and associated documentation files (the "Software"), to deal in
	the Software without restriction, including without limitation the rights to
	use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
	of the Software, and to permit persons to whom the Software is furnished to do
	so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.
*/
package stencil.core.engine.scene 
{
	import flash.geom.Rectangle;
	import stencil.core.engine.IDisposable;
	import stencil.core.engine.IGrid;
	import stencil.core.engine.IMapArea;
	import stencil.core.engine.ITileSection;
	import stencil.core.engine.Position;
	import stencil.core.engine.Box;
	import stencil.core.engine.ISceneObject;
	import stencil.core.engine.IMapGraph;
	import stencil.core.engine.TileSettings;
	
	/**
	 * ...
	 * @author Max Zhuravkov
	 */
	public interface ISceneStructure extends ISceneObjectRegistry, IDisposable {
		
		/**
		 * The grid used to determine object positions.
		 */
		function set objectGrid(value:IGrid):void;
		
		function get objectGrid():IGrid;
		
		/**
		 * The grid used to determine tile positions.
		 */
		function set tileGrid(value:IGrid):void;
		
		function get tileGrid():IGrid;
		
		/**
		 * The scene nodes.
		 */
		function get sceneNodes():Array;
		
		/**
		 * The boundaries in grid coordinates.
		 */
		function get boundaries():Rectangle;
		
		/**
		 * The boundaries in global coordinates.
		 */
		function get globalBoundaries():Rectangle;
		
		/**
		 * The tile settings.
		 */
		function set tileSettings(value:TileSettings):void;
		
		function get tileSettings():TileSettings;
		
		/**
		 * The map graph.
		 */
		function set mapGraph(value:IMapGraph):void;
		 
		function get mapGraph():IMapGraph;

		/**
		 * Initializes the structure. 
		 */
		function init():void;
		
		/**
		 * Returns the scene node for the given position.
		 * 
		 * @param	p	the posirion.
		 */
		function getSceneNode(p:Position):ISceneNode;
		
		/**
		 * Adds an object to scene.
		 * 
		 * @param	object	the object.
		 * 
		 * @return	if object was successfully added returns 'true'. when as the result of add operation this given object 
		 * was removed from scene (it was outside scene boundaries at that time) this method returns 'false'.
		 */
		function addObject(object:ISceneObject):Boolean;
		
		/**
		 * Removes the object from scene.
		 * 
		 * @param	object	the scene object.
		 * 
		 * @return	'true' when an object was successfully removed and 'false' otherwise.
		 */
		function removeObject(object:ISceneObject):Boolean;
		
		
		/**
		 * Updates position of the specified object at scene.
		 * 
		 * @param	object	the scene object.
		 * 
		 * @return	when as the result of this operation the given object was removed from scene
		 * (it was outside scene boundaries at that time) this method returns 'false'.
		 * Otherwise it returns 'true'.
		 */
		function updateObject(object:ISceneObject):Boolean;
		
		/**
		 * Returns 'true' if this scene contains the given object.
		 * 
		 * @param	object	the object to test.
		 * 
		 * @return
		 */
		function containsObject(object:ISceneObject):Boolean;
		
		/**
		 * Returns the object with the given indenifier.
		 * 
		 * @param	id	the identifier.
		 * 
		 * @return
		 */
		function getObject(id:String):ISceneObject;

		/**
		 * Returns an array of scene objects found within the given area.
		 * 
		 * @param	area	the area  (in global space coordinates).
		 * @param	filter	the filter function (SceneObject => Boolean).
		 * 
		 * @return
		 */
		function getObjects(area:Rectangle, filter:Function = null):Array;
		
		/**
		 * Returns an array of objects that occupy the given position.
		 * 
		 * @param	p	the position.
		 * @param	filter	the filter function (SceneObject => Boolean).
		 * 
		 * @return
		 */
		function getObjectsAt(p:Position, filter:Function = null):Array;
		
		/**
		 * Returns the area object which contains tile sections and other objects that can be found within the given rectangular bounds.
		 * 
		 * @param	rect	the rectangular bounds (in global space coordinates).
		 * @param	filter	the filter function (SceneObject => Boolean).
		 * 
		 * @return
		 */
		function getArea(rect:Rectangle, filter:Function = null):IMapArea;
	}
	
}